# -*- coding:utf-8 -*-
"""
@author: Jioccer
@time: 2023/9/9 13:55 
@file: 解除屏蔽.py
@project: 一键关闭Windows更新
@describe: TODO
"""

import winreg

# 定义注册表键路径
key_path = r"SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"

try:
    # 打开注册表键
    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path, 0, winreg.KEY_WRITE) as key:

        # 删除指定的注册表值
        values_to_delete = [
            "FlightSettingsMaxPauseDays",
            "PauseFeatureUpdatesStartTime",
            "PauseFeatureUpdatesEndTime",
            "PauseQualityUpdatesStartTime",
            "PauseQualityUpdatesEndTime",
            "PauseUpdatesStartTime",
            "PauseUpdatesExpiryTime",
        ]

        for value_name in values_to_delete:
            try:
                winreg.DeleteValue(key, value_name)
                print(f"已删除注册表值: {value_name}")
            except FileNotFoundError:
                print(f"注册表值不存在: {value_name}")

    print("注册表操作执行完成")

except Exception as e:
    print(f"发生错误: {e}")
